<%@ page language="Java" import="java.util.*,descriptor.*,cv.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%
	QueryListDescriptor queriesList = (QueryListDescriptor)request.getAttribute("queriesList");
	String error1 = (String)request.getAttribute("error1");
	String error2 = (String)request.getAttribute("error2");
%>

<%	
	String notif = "";
	if(error1 != null)
	{
		notif = "<p style=\"color:red; font-size: 10px;\">" + error1 + "<p>";
	}
%>

<html>
	<jsp:include page="StudentHeader.jsp" >
		<jsp:param name="pageTitle" value="Work Placement Management System - Student" />
	</jsp:include>
	<body OnLoad="showmenu(document.getElementById('smenu5'));">
		<jsp:include page="StudentPageHeader.jsp"></jsp:include>
		<div id="container">
			<jsp:include page="StudentMenu.jsp" ></jsp:include>
			<div id="content">
				<h3 class="posttitle">Student - All Queries</h3>
				<div class="entry">
					<%= notif %>
					<%
							int sizeList = queriesList.sizeQueriesList(); 
							if(sizeList>0)
							{
					%>
					<table rules="all">
						<thead>
							<tr><th>Academic Supervisor Name</th><th>Offer</th><th>Message</th><th>Status</th><th></th></tr>
						</thead>
					<%
								for(int i=0; i<sizeList; i++)
								{
									int id =  queriesList.getQueryList().get(i).getID();
									String academicSup = queriesList.getQueryList().get(i).getAcademicSupName();
									String offer = queriesList.getQueryList().get(i).getOfferName();
									String msg = queriesList.getQueryList().get(i).getMessage();
									int status = queriesList.getQueryList().get(i).getStatus();
									String style = "";
									String state = "";
									if(status == 1)
									{
										style = "style=\"background-color: #66ee00;\"";
										state = "ACCEPTED";
									}
									else
									{
										if(status == -1)
										{
											style = "style=\"background-color: #ff3333; color= white;\"";
											state = "REJECTED";
										}
										else
										{
											state = "Waiting for answer";
										}
									}
					%>
						<tr <%= style %>>
							<td><%= academicSup %></td>
							<td><%= offer %></td>
							<td><%= msg %></td>
							<td><%= state %></td>
							<td>
					<%
									if(status == -1)
									{
					%>
								
								<form name="delete<%= i %>" method="post">
									<input type="hidden" name="action" value="deleteQuery">
									<input type="hidden" name="queryID" value="<%= id %>"> 
									<input id="query<%= i %>" type="hidden" name="filename" value="this query rejected ?">    
								</form> 
								<a href="javascript:openDeleteWindow(document.getElementById('query<%= i %>'),document.delete<%= i %>);" title="Delete this rejected query">Delete</a>
							
						
				<%					}
				%>
							</td>
				<% 
								}
				%>
						</tr>
					</table>
				<%
							}
							else
							{ 
								if(error2 != null)
								{
				%>
								<p><%= error2 %></p>
								<form name="sendQuery" method="post">
									<input type="hidden" name="action" value="sendQuery">     
								</form> 
								<a href="javascript:document.sendQuery.submit();" title="Send a query">Send a query</a>
								
				<%	 			}
							} 
				%>
				</div>
	    	</div>
			<jsp:include page="StudentPageFooter.jsp"></jsp:include>
		</div>
	</body>
</html>